package com.xxx.base.spring;

import com.xxx.base.util.Log;
import org.springframework.beans.factory.BeanFactory;

import javax.annotation.Resource;

/**
 * Created by xxb on 18/5/24.
 */
public class BaseBean {
    protected final Log log = Log.of(getClass());

    @Resource
    protected BeanFactory beanFactory;


    /**
     * 当对象被aop, 调用内部aop方法 不会生效, 要用 me()获取正确的this 值再调.
     * @param <T>
     * @return
     */
    protected <T> T me() {
        Class<? extends BaseBean> clz = getClass();
        return beanFactory.getBean((Class<T>) clz);
    }
}
